<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">

<div>
    <form id="myform" class="form-horizontal" method="post" action="{:U('Block/edit')}">
        <div class="form-group">
            <label class="control-label col-md-2">名称:</label>
            <div class="col-md-8">
                <input type="text" class="form-control" name="name" id="name" value="{$vo.name}">
            </div>
        </div>
        <div class="form-group env-class">
            <label class="control-label col-md-2">碎片类型:</label>
            <div class="col-md-8">
            <div class="radio-inline">
                <label>
                <input type="radio" name="type" <eq name="vo.type" value="url">checked</eq> value="url">链接地址
                </label>
            </div>
            <div class="radio-inline">
                <label>
                    <input type="radio" name="type" <eq name="vo.type" value="img">checked</eq> value="img">图片
                </label>
            </div>
            <div class="radio-inline">
                <label>
                    <input type="radio" name="type" <eq name="vo.type" value="text">checked</eq> value="text">文本
                </label>
            </div>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">内容:</label>
            <div class="col-md-8">
                {if $vo['type'] != 'text'}
                <input type="text" class="form-control" name="content" value="{$vo.content}">
                {else}
                    {: $Form->editor(array('field'=>'content','moduleid'=>'231','setup'=>array('toolbar'=>'full','flashupload'=>'1')),$vo[content])}
                {/if}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">所属组:</label>
            <div class="col-md-4">
                <select name="group" class="form-control">
                    <option value="1">pc端</option>
                    <option value="2">wap端</option>
                </select>
            </div>
        </div>
        <div class="form-actions">
            <input type="hidden" name="id" value="{$vo.id}">
            <input type="submit" value="提交" class="btn btn-primary" />
            <a class="btn btn-primary" href="javascript:window.history.go(-1);">返回</a>
        </div>
    </form>

</div>
</block>

<block name="script">
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });
            } else {
                layer.msg(data.info, {
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }
    </script>
</block>